//
//  RenHouseTopMenu.m
//  CenturyCity
//
//  Created by beisheng03 on 2018/1/17.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "RenHouseTopMenu.h"
#import "RenHouseCarySubCell.h"
#import "PulishRentInfoVC.h"
#import "BaseNavigationController.h"
#import "RentHouseCategoryVC.h"
#import "BaseNavigationController.h"
#import "LoginViewController.h"
@interface RenHouseTopMenu ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionVeiw;


@end

@implementation RenHouseTopMenu


- (void)awakeFromNib {
    [super awakeFromNib];
    
    //    self.layoutMargins = UIEdgeInsetsZero;
    
    [self.myCollectionVeiw registerNib:[UINib nibWithNibName:NSStringFromClass([RenHouseCarySubCell class]) bundle:nil] forCellWithReuseIdentifier:[RenHouseCarySubCell identifierStr]];
    
    self.myCollectionVeiw.backgroundColor = [UIColor whiteColor];
    
    self.myCollectionVeiw.delegate = self;
    
    self.myCollectionVeiw.dataSource = self;
    

}





- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    
    return 1;
    
    
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return 4;
    
    //    return self.models.count;
    
    
}


- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
    RenHouseCarySubCell *temp = (RenHouseCarySubCell *)[collectionView dequeueReusableCellWithReuseIdentifier:[RenHouseCarySubCell identifierStr] forIndexPath:indexPath];
    
    temp.index = indexPath;
    
    
    return temp;
    
    
    
}


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    [[NSNotificationCenter defaultCenter]postNotificationName:@"putAwayView" object:nil];
    
    
    if (indexPath.item == 0) {
        RentHouseCategoryVC *temp = [[RentHouseCategoryVC alloc]init];
        temp.type = @"0";
        [self.viewController.navigationController pushViewController:temp animated:YES];
    }
    
    if (indexPath.item == 1) {
        RentHouseCategoryVC *temp = [[RentHouseCategoryVC alloc]init];
        temp.type = @"1";
        [self.viewController.navigationController pushViewController:temp animated:YES];
    }
    
    
    
    if (indexPath.item == 2) {
        RentHouseCategoryVC *temp = [[RentHouseCategoryVC alloc]init];
        temp.type = @"2";
        [self.viewController.navigationController pushViewController:temp animated:YES];
    }
    
    
    
    if (indexPath.item == 3) {
        
        if (myViewModel.userIsLogin) {
            PulishRentInfoVC *rentInfoVC = [[PulishRentInfoVC alloc]initWithStyle:UITableViewStyleGrouped];
            
            //            BaseNavigationController *nav = [[BaseNavigationController alloc]initWithRootViewController:rentInfoVC];
            
            //            nav.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
            
            //            [self.viewController presentViewController:nav animated:YES completion:nil];
            
            [self.viewController.navigationController pushViewController:rentInfoVC animated:YES];
            
        } else {
            
            BaseNavigationController *nav = [[BaseNavigationController alloc]initWithRootViewController:[[LoginViewController alloc]init]];
            
            [self.viewController presentViewController:nav animated:YES completion:nil];
        }
        
        
    }
    
    
    
    
    
    
}

@end
